package com.googlecode.wstester.handlers

import xml.XML
import com.googlecode.wstester.config.RequestConfig
import com.googlecode.wstester.config.utils.{PlainXML}
import utils.Send

/**
 * Created by IntelliJ IDEA.
 * User: pablo
 * Date: 2010-07-14
 * Time: 12:13:34
 */

class OneShotTestHandler(var requestConfig : RequestConfig, var testDirName: String) {
  def performRequest = {
    requestConfig.requestType match {
      case t: PlainXML => {
        val request = XML.load(testDirName+"/"+requestConfig.requestFileName);
        val requesthandler = new RequestHandler(request.toString);
        requesthandler.targetURL = requestConfig.targetUrl;
        requesthandler.soapAction = requestConfig.soapAction;
        requesthandler.start;
        requesthandler ! Send;
      }
      case _ => throw new IllegalArgumentException("Unknown request type");
    }
  }
}